<?php include_once ('function/check_login_function.php'); onlyValid(); onlyPatient();?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Health Tracker</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Health Tracker">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
    <link rel="shortcut icon" href="ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
  </head>

  <body>


<?php include_once('nav.php'); ?>
      
    <div class="container">
    <div class="row">
    <div class="span8">
      <h1>Log</h1>
					<?php
	  					if (isset($_SESSION['message'])) {
						foreach ($_SESSION['message'] as $message) {
							echo '<div class="alert">'.constant($message) . '</div>';
						}
						unset($_SESSION['message']);
					} 
					?>
							
				<?php if ($user->getRole() === 'patient') {?>
					<?php include_once('symptom_form.php'); ?>
					
					<?php $symptom_list = $user->getSymptomList(); ?>
					<?php if ($symptom_list !== null) {?>
					<table class="table">
					<tr>
					<th>Name</th>
					<th>Level</th>
					<th>Note</th>
					<th>Date</th>
					<th></th>
					</tr>
					<?php 
						
							foreach ($symptom_list as $symptom) {
								echo '<tr>';
								echo '<td>' . $symptom['symptom_name'] . '</td>';
								echo '<td>' . $symptom['symptom_level'] . '</td>';
								echo '<td>' . $symptom['symptom_note'] . '</td>';
								echo '<td>' . $symptom['created_at'] . '</td>';
								echo '<td>';
									echo '<form action="function/form_function.php" method="POST">';
									echo '<input type="hidden" id="symptomID" name="symptomID" value="' . $symptom['symptom_id'] . '"/>';
									echo '<input type="hidden" id="from" name="from" value="symptom.php"/>'; 
									echo '<input type="submit" name="removeSymptom" value="Remove Symptom" class="btn btn-primary"/> ';
									echo' </form>';
								echo '</td>';
								echo '</tr>';
							}
						}
					?>
					</table>				
					
				<?php } ?>
				
    </div>
    </div>
    </div> <!-- /container -->
  </body>
</html>